<?php						
						
include 'db/db_Connect.php';            


	                
							
$query="SELECT User.user_id, User.first_name, User.last_name, User.zipcode, User.family_in_need_match, AdoptionPreferences.num_adults, AdoptionPreferences.num_children, AdoptionPreferences.toyOK, AdoptionPreferences.deliveryOK, AdoptionPreferences.spanishOK"
			. " FROM User INNER JOIN AdoptionPreferences ON User.user_id = AdoptionPreferences.user_id";							
$adopterResult = mysql_query($query);
							
while($row = mysql_fetch_array($adopterResult)){
	
	$family_in_need_id = $row['family_in_need_match'];
	$family_in_need_Result = mysql_query("SELECT first_name, last_name FROM FamilyMembers WHERE family_id = '$family_in_need_id' AND contact_1='1'");
	$family_in_need = mysql_fetch_array($family_in_need_Result);
	$familyName = $family_in_need['first_name']." ".$family_in_need['last_name'];

			
				echo    "<tr id=\"".$row['user_id']."\"><td>"
							. $row['user_id']
							. "</td><td class=\"center\">"
			                . $row['first_name'] . " " . $row['last_name']
			                . "</td><td class=\"center\">" 			                
			                . $row['zipcode']            
			                . "</td><td class=\"center\">" 
							    . $row['num_adults']
			                . "</td><td class=\"center\">"
								 . $row['num_children']
			                . "</td><td class=\"center\">" 			                 
			                . $row['toyOK']
			                . "</td><td class=\"center\">" 
			                . $row['deliveryOK']
								 . "</td><td class=\"center\">" 
			                . $row['spanishOK']
								 . "</td><td class=\"center\">";
								 
								 if ($family_in_need_id == null){
								 		echo "";
								 	} else {
								 		
								 		echo "<a href=\"familySummary.php?family_id=".$family_in_need_id."\">$familyName</a>";															 								 		
								 	}
								   		                			                
			                echo "</td><td>" 
 										//. "<a class=\"btn btn-info table-action-EditUser\" >"
 										. "<a class=\"btn btn-info\" href=\"adopterSummary.php?id=" .$row['user_id'] . "\">"
										. "<i class=\"icon-eye-open icon-white\"></i>"  
											." View"                                            
								  . "</a></center>"
							/*	  . " "
								  . "<a class=\"btn btn-danger table-action-deletelink\" id=\"btnDeleteRow\" href=\"#\">"
										. "<i class=\"icon-trash icon-white\"></i>" 
											. "Delete"
								 . "</a></center>" */                  
			                . "</td></tr>";
	
}

include 'db/db_Close.php';			
?>						
